package database;

import enums.SearchType;
import Other.Glob;


public class MyAddressee extends NewTirDataBase{
	
	private String addresseeID;
	private String name;
	private String address;
	private String postcode;
	private String town;
	private String province;
	private String codeCountryID;
	private String countryName;
	private String phoneNumber;
	private String fax;
	private String nif;
	private String contact;
	private String email;
	
	private static final int ADDRESEE_ID = 0;
	private static final int NAME = 1;
	private static final int ADDRESS = 2;
	private static final int POSTCODE = 3;
	private static final int TOWN = 4;
	private static final int PROVINCE = 5; 
	private static final int CODE_COUNTRY_ID = 6;
	private static final int PHONE_NUMBER = 7;
	private static final int FAX = 8;
	private static final int NIF = 9;
	private static final int CONTACT = 10;
	private static final int EMAIL = 11;
	

	
	public MyAddressee() {
		
	}
	
	public MyAddressee (String[] data) {
		
		super();
		this.addresseeID = data[ADDRESEE_ID];
		this.name = data[NAME];
		this.address = data[ADDRESS];
		this.postcode = data[POSTCODE];
		this.town = data[TOWN];
		this.province = data[PROVINCE];
		this.codeCountryID = data[CODE_COUNTRY_ID];
		this.phoneNumber = data[PHONE_NUMBER];
		this.fax = data[FAX];
		this.nif = data[NIF];
		this.contact = data[CONTACT];
		this.email = data[EMAIL];
		
		
		countryName ="";
		
		Glob.setType(SearchType.COUNTRY);
		
		for (NewTirDataBase c : DatabaseExtension.getTableID("Select * from country")) {
			if (((MyCountry) c).getCountryID().trim().replaceAll("\n", "").equals(codeCountryID)) {
				countryName = String.format("%s",((MyCountry) c).getCountryName());
			}
				
		}
		
		
		Glob.type = SearchType.ADDRESSEE;
		//System.out.println("Search type after looking for the country " + Glob.type);
	}

	public String getAddresseeID() {
		return addresseeID;
	}

	public void setAddresseeID(String addresseeID) {
		this.addresseeID = addresseeID;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPostcode() {
		return postcode;
	}

	public void setPostcode(String postcode) {
		this.postcode = postcode;
	}

	public String getTown() {
		return town;
	}

	public void setTown(String town) {
		this.town = town;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCodeCountryID() {
		return codeCountryID;
	}

	public void setCodeCountryID(String codeCountryID) {
		this.codeCountryID = codeCountryID;
	}

	public String getCountryName() {
		return countryName;
	}

	public void setCountryName(String countryName) {
		this.countryName = countryName;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getNif() {
		return nif;
	}

	public void setNif(String nif) {
		this.nif = nif;
	}

	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	
	
}
